/*
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2025-06-04 13:56:19
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-05 17:40:59
 * @FilePath: \vue3_admin_template\project\src\api\product\attr\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
//平台属性API接口
import request from '@/utils/request'
import type { ResponseData, AttrResponseData, Attr } from './type.ts'
//属性管理模块接口地址
enum API {
  //获取一级分类接口
  C1_URL = '/admin/product/getCategory1',
  //获取二级分类接口
  C2_URL = '/admin/product/getCategory2/',
  //获取三级分类接口
  C3_URL = '/admin/product/getCategory3/',
  //获取整个三级分类属性接口
  DELETE_URL = '/admin/product/baseTrademark/remove/',
  //获取分类下已有的属性和属性值
  ATTR_URL = '/admin/product/attrInfoList/',
  //添加或修改已有商品基础属性接口
  ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
  //删除某一个已有属性
  DELETEATTR_URL = '/admin/product/deleteAttr/',
}
//获取一级分类接口方法
export const reqC1 = () => request.get<any, ResponseData>(API.C1_URL)
//获取二级分类接口方法
export const reqC2 = (catrgory1Id: number | string) =>
  request.get<any, ResponseData>(API.C2_URL + catrgory1Id)
//获取三级分类接口方法
export const reqC3 = (catrgory2Id: number | string) =>
  request.get<any, ResponseData>(API.C3_URL + catrgory2Id)

//获取分类下已有的属性和属性值接口方法
export const reqAttr = (
  catrgory1Id: string | number,
  catrgory2Id: string | number,
  catrgory3Id: string | number,
) =>
  request.get<any, AttrResponseData>(
    API.ATTR_URL + `${catrgory1Id}/${catrgory2Id}/${catrgory3Id}`,
  )

//新增或修改已有属性接口方法
export const reqAddOrUpdateAttr = (data: Attr) =>
  request.post<any, any>(API.ADDORUPDATEATTR_URL, data)
//删除已有属性方法
export const reqRemoveAttr = (attrId: number) =>
  request.delete<any, any>(API.DELETEATTR_URL + attrId)
